/* @(#)GSLoginAction.java    
 *
 * Project: BUS
 *
 * Modify Information:
 * =============================================================================
 *   Author       Date       Description
 *   ------------ ---------- ---------------------------------------------------
 *   Simonyi Peng 2006-2-7    建立
 *
 * Copyright Notice:
 * =============================================================================
 *    Copyright (c) 2001-2006 Beijing HiTRUST Technology Co., Ltd. 1808 Room, 
 *        Science & Technology Building, No. 9 South Street, Zhong Guan Cun, 
 *        Haidian District, Beijing ,100081, China All rights reserved.
 *
 *    This software is the confidential and proprietary information of
 *        Beijing HiTRUST Technology Co., Ltd. ("Confidential Information").
 *        You shall not disclose such Confidential Information and shall use it
 *        only in accordance with the terms of the license agreement you entered
 *        into with HiTRUST.
 *
 * Warning:
 * =============================================================================
 * 
 */
package com.hitrust.gs.action;

import java.util.ArrayList;

import system.LoginContext;

import com.hitrust.gs.bean.GSOperatorBean;
import com.hitrust.gs.business.GSOperatorProcessor;
import com.hitrust.gs.business.GSOrgProcessor;
import com.hitrust.gs.business.GSOrderProcesser;
import com.hitrust.gs.business.GSUniteGwProcessor;
import com.hitrust.gs.form.GSOrderSubmitForm;
import com.hitrust.gs.lib.GSBaseConstants;
import com.hitrust.gs.lib.GSLogWriter;
import com.hitrust.gs.service.GSBaseAction;
import com.hitrust.gs.service.GSBaseForm;
import com.hitrust.gs.util.exception.*;
import com.hitrust.gs.util.page.ResultProcess;
import com.hitrust.gs.vo.GSOrderAuditQueryVO;

public class GSOrderReviewQueryAction extends GSBaseAction {
    public String execute(GSBaseForm aForm) throws GSException {
        LoginContext operatorBean = (LoginContext) aForm.getSession().getAttribute(GSBaseConstants.LOGIN);
        GSOrderProcesser ordProcesser = new GSOrderProcesser();
        GSOrderSubmitForm tForm = (GSOrderSubmitForm) aForm;
        GSOrderAuditQueryVO oaqVO = new GSOrderAuditQueryVO();
        oaqVO.orderId = tForm.getOrderId();
        oaqVO.deptId = tForm.getOrderDept();
        oaqVO.concentricityId = tForm.getConcentricityId();
        oaqVO.manufInfo = tForm.getManufInfo();
        oaqVO.beginDate = tForm.getOrderCreateDateStr();
        oaqVO.endDate = tForm.getOrderCreateDateEnd();
        oaqVO.drawingpiececode = tForm.getDrawingpiececode();
        oaqVO.isSW=tForm.getIsSW();
        if (aForm.getRequest().getAttribute("ISQUERYCONDITIONEXIST") != null) {
            // 是执行完返回的，读出查询条件
            oaqVO = (GSOrderAuditQueryVO) aForm.getSession().getAttribute("QUERYCONDITION");
        } else {
            // 初次查询，缓存查询条件
            aForm.getSession().setAttribute("QUERYCONDITION", oaqVO);
        }
        try {
            // 先查询出当前初审人员有权审核的所有订单
            ArrayList orderAry = ordProcesser.getAllReviewNeedOrder(operatorBean, oaqVO);
            ResultProcess tRsProc = new ResultProcess();
            tRsProc.setResult(orderAry);
            tForm.getRequest().setAttribute("orderlist", tRsProc);
            GSUniteGwProcessor uniteProcess = new GSUniteGwProcessor();
            ArrayList ary = uniteProcess.getWareHouseLevelName(operatorBean.getLoginWarehouseCode(),operatorBean.getLoginWarehouseCode());
            aForm.getRequest().setAttribute("organdaddr", ary);
        } catch (GSException e) {
            aForm.getRequest().setAttribute("action", "A100901.do");
            throw e;
        } catch (Exception ex) {
            GSLogWriter.error(this, ex.toString());
            tForm.getRequest().setAttribute("action", "A100901.do");
            throw new GSException(GSException.E20054, GSException.E20054_MSG);
        }
        return GSBaseConstants.FORWARD_SUCCESS;
    }
}
